<!-- Generated automatically from an XML file of the same name.
     Copyright: Stephen J. Sangwine and Nicolas Le Bihan, 2008-2010.
--><html><head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
   <title>write :: Functions (Quaternion Toolbox Function Reference)
</title><link rel="stylesheet" href="qtfmstyle.css" type="text/css"></head><body><h1>Quaternion Function Reference</h1><h2>write</h2>
<p>Output a quaternion array to a text file.</p>
<h2>Syntax</h2><p><tt>write(filename, format, a)</tt></p>
<h2>Description</h2>
<p>
This function writes a text file which is designed to be easily
read into other software.  The
first line of the file contains two integer values giving the
number of rows and columns in the file.  The quaternion values
then follow in raster order, that is with the column index varying
most rapidly. Each quaternion value occupies one line in the file,
and consists of four floating-point values, separated by spaces.
</p>
<p>
The format parameter may be omitted, in which case a default is
assumed which outputs sufficient digits to represent double values
with no loss of accuracy. Otherwise the format is a string (see the
standard MATLAB&reg; function <tt>fprintf</tt> for details).
</p>
<p>
If the parameter <tt>a</tt> is a pure quaternion, only three components
are written per quaternion.
</p>
<p>
The text file written by this function may be read by the matching function
<tt>read</tt>.
</p>

<h2>Examples</h2>
<pre>
&gt;&gt; q = randq(2)
 
q = 2x2 quaternion array
 
&gt;&gt; show(q)
 
q.S =
 
    0.4196    0.2015
    0.2664   -0.5665

q.X =
 
    0.3533   -0.0095
    0.1953    0.3631

q.Y =
 
    0.8358    0.9786
   -0.8679   -0.3181

q.Z =
 
   -0.0225    0.0398
    0.3710    0.6679

&gt;&gt; write('data.txt', q)
</pre>
The resulting text file is as follows:
<pre>
       2        2
 +4.1963850834385363e-01  +3.5330836341397237e-01  +8.3580546214538765e-01  -2.2493379128557589e-02
 +2.0153918465836959e-01  -9.5148222156437885e-03  +9.7862378239152092e-01  +3.9836136147441963e-02
 +2.6635283946883026e-01  +1.9532770507814057e-01  -8.6792292331469123e-01  +3.7096233194312195e-01
 -5.6651136993926687e-01  +3.6311064121797937e-01  -3.1805954904022421e-01  +6.6787248276009414e-01
</pre>

<h2>See Also</h2>QTFM function: <a href="read.html">read</a><br>MATLAB&reg; function: <a href="matlab:doc fprintf">fprintf</a><br>
<h4>&copy; 2008-2010 Stephen J. Sangwine and Nicolas Le Bihan</h4><p><a href="license.html">License terms.</a></p></body></html>